package com.ncut.product.mapper;

import com.github.pagehelper.Page;
import com.ncut.annotation.AutoFill;
import com.ncut.dto.SetmealPageQueryDTO;
import com.ncut.entity.Setmeal;
import com.ncut.enumeration.OperationType;
import com.ncut.vo.DishItemVO;
import com.ncut.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @FileName SetmealMapper
 * @Description
 * @Author Sword
 * @date 2025-07-09
 **/

@Mapper
public interface SetmealMapper {

    /**
     * 新增套餐
     *
     * @param setmeal
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Setmeal setmeal);

    /**
     * 套餐分页查询
     *
     * @param setmealPageQueryDTO
     * @return
     */
    Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);

    /**
     * 根据id查询套餐数据
     *
     * @param id
     * @return
     */
    @Select("select * from setmeal where id = #{id}")
    Setmeal getById(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void update(Setmeal setmeal);

    /**
     * 批量删除套餐
     *
     * @param ids
     */
    void deleteBatch(List<Long> ids);

    /**
     * 根据分类id查询套餐
     *
     * @param setmeal
     * @return
     */
    List<Setmeal> list(Setmeal setmeal);

    /**
     * 根据套餐id查询菜品选项
     *
     * @param id
     * @return
     */
    List<DishItemVO> getDishItemById(Long id);

    /**
     * 统计套餐启售停售数量
     *
     * @param map
     * @return
     */
    @Select("select COUNT(*) from setmeal where status = #{status}")
    Integer countByMap(Map map);
}
